package com.example.demo.controller;

import com.example.demo.config.AppConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@Slf4j
@RequestMapping("/chat")
public class ChatController {


    @PostMapping("/login")
    public void login(HttpServletRequest request, String username) {
        HttpSession session = request.getSession(true);
        session.setAttribute(AppConfig.HTTP_SESSION_KEY,username);
        log.info(username + " 登录成功.");
    }
}
